<?php
/**
 * default template file for iTOEstate view of iTOEstate component
 * @package		iTO
 * @subpackage	Components
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @author		Kostyantyn Didenko
 * @license		License GNU General Public License version 2 or later
 */
 
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import the Joomla modellist library
jimport('joomla.application.component.modellist');

/**
 * iTOEstate Model
 */
class iTOEstateModeliTOEstate extends JModelList
{
	/**
	 * Method to build an SQL query to load the list data.
	 *
	 * @return	string	An SQL query
	 */
	protected function getListQuery() 
	{		
		// Create a new query object.
		$db = JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select('l.id, l.description, l.state, c.alias AS category, t.name AS type, l.crdate, l.price');
		$query->from('#__itoestate AS l');
		$query->innerJoin('#__itoestate_categories AS c ON l.category_id = c.id');
		$query->innerJoin('#__itoestate_types AS t ON l.type_id = t.id');
		$query->innerJoin('#__itoestate_locations AS r ON l.region_id = r.id');
		$query->order('l.id DESC');
		
		return $query;
	}
}
